<?php

namespace app\admin\model\wanlshop;

use think\Model;
use app\admin\model\User;

class ShareOrder extends Model
{
    // 表名
    protected $name = 'wanlshop_share_order';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    public function statusList()
    {
        return [
            0 => '待打款',
            1 => '已打款',
            2 => '打款失败',
        ];
    }

    protected $append = [
        'status_text'
    ];

    public function getStatusTextAttr()
    {
        return $this->statusList()[$this->status];
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    public function orders()
    {
        return $this->belongsTo(Order::class, 'order_id', 'id');
    }

    public function share()
    {
        return $this->belongsTo(Share::class, 'parent_share_id');
    }

    public function shop()
    {
        return $this->belongsTo(Shop::class, 'shop_id', 'id');
    }

    public function getStatusList()
    {
        return ['0' => __('待支付'), '1' => __('支付成功'), '2' => __('支付失败')];
    }
}
